package cc.eddic.pratice.programmingparadigms.nginxlog.impl;

import cc.eddic.pratice.programmingparadigms.nginxlog.TextFileReader;
import lombok.extern.slf4j.Slf4j;
import lombok.val;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

@Slf4j
public class TextFileReaderImpl implements TextFileReader {
    @Override
    public Stream<String> read(String textFileName) throws IOException {
        val p = Paths.get(textFileName);
        return Files.lines(p);
    }

    @Override
    public List<String> readList(String textFileName) throws IOException {
        return read(textFileName).collect(Collectors.toList());
    }
}
